package com.mtsmda.ws.rest.jboss.services;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;

@Path("/headerParam")
public class HeaderParam {

	@GET
	@Path("/user-agent")
	public Response getUserAgent(
			@javax.ws.rs.HeaderParam("user-agent") String userAgent) {

		return Response.status(200)
				.entity(new String("user - agent: " + userAgent)).build();
	}

	@GET
	@Path("/language")
	public Response getAcceptLanguage(@Context HttpHeaders headers) {
		StringBuilder language = new StringBuilder(headers.getRequestHeader(
				"accept-language").get(0));
		language.append("<br><br>");

		for (String header : headers.getRequestHeaders().keySet()) {
			language.append(header).append(" - <b>")
					.append(headers.getRequestHeader(header))
					.append("</b><br>");
		}

		return Response.status(200).entity(language.toString()).build();
	}

}